<?php
session_start();
include_once("function_right.php");
if(!JudgeUserRight()) return FALSE;
?>

<?php
include_once "function_vpn_ssl.php";

$CA = $_POST['ca'];
$SERVER = $_POST['server'];
$DH= $_POST['dh'];

$in_array['Time'] = $_POST['time'];
if (trim($in_array['Time']) == "" )
	$in_array['Time'] = 365;
$in_array['Org'] = $_POST['org'];
if (trim($in_array['Org']) == "" )
	$in_array['Org'] = "VPN";
$in_array['City'] = $_POST['city'];
if (trim($in_array['City']) == "" )
	$in_array['City'] = "BeiJing";
$in_array['State'] = $_POST['state'];
if (trim($in_array['State']) == "" )
	$in_array['State'] = "BeiJing";
$in_array['User'] = $_POST['user'];
if (trim($in_array['User']) == "" )
	$in_array['User'] = "vpn_server";
$in_array['Email'] = $_POST['email'];
if (trim($in_array['Email']) == "" )
	$in_array['Email'] = "admin@angate.net";
//print_r ($in_array);

$crt = new CCertificate();
$num = 0;
$crt -> edit_item_by_num($num, $in_array); 
$crt -> Apply();

include_once "function_misc_log.php";
logger("Modify", $in_array, "SSL_VPN_CRT");

//print_r( $_POST);

$log = array();
if ($DH == "1"){
	$crt -> CreateCA();
	$log['Type'] = "DH";
	logger("Create", $log, "SSL_VPN_CRT");
}	
if ($CA == "1"){
	$crt -> CreateCA();
	$log['Type'] = "CA";
	logger("Create", $log, "SSL_VPN_CRT");
}	
if ($SERVER == "1"){
	$crt -> CreateSERVER();
	$log['Type'] = "SERVER";
	logger("Create", $log, "SSL_VPN_CRT");
}	

echo("<meta http-equiv='refresh'content=0;URL='vpn_ssl_crt_manage.php'>");

?>
